#!/usr/bin/make -f
# Debian rules file, originally written by Joey Hess and Craig Small.
# Modified for scim-waitzar by Seth N. Hetu


# Set the host type, for cross-compilation, or just to save time later.
DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)


# Shared library: version
version=2.0.5
major=2

# Run "./configure"
config.status: configure
	dh_testdir
ifneq "$(wildcard /usr/share/misc/config.sub)" ""
	cp -f /usr/share/misc/config.sub config.sub
endif
ifneq "$(wildcard /usr/share/misc/config.guess)" ""
	cp -f /usr/share/misc/config.guess config.guess
endif
	./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs"


# Build 
build: build-stamp
build-stamp:  config.status
	dh_testdir

	# compile
	$(MAKE)

	touch $@

# Clean:
clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp 

	#Clean the package (and keep useful warnings)
	[ ! -f Makefile ] || $(MAKE) distclean
	rm -f config.sub config.guess

	dh_clean 

# Install:
install: build
	dh_testdir
	dh_testroot
	dh_clean -k 
	dh_installdirs

	# Install int debian/tmp
	$(MAKE) DESTDIR=$(CURDIR)/debian/tmp install


# Build: architecture independent (keep for later)
binary-indep: build install


# Build: architecture dependent
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs ChangeLog
	dh_installdocs
	dh_installexamples
	dh_installman
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install 
